﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Manage_luqu : System.Web.UI.Page
{
    BLL.RegistrationBll regBll = new BLL.RegistrationBll();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindTable();
        }
    }

    private void BindTable()
    {
        int regId = int.Parse(Request.QueryString["id"]);
        Model.Registration reg = regBll.GetRegistrationById(regId);

        lb_Account.Text = reg.regAccount;
        lb_Address.Text = reg.regAddress;
        lb_Degree.Text = reg.regDegree;
        lb_IDCard.Text = reg.regIDCard;
        lb_Mail.Text = reg.regMail;
        lb_Phone.Text = reg.regPhone;
        lb_ProName.Text = reg.proName;
        lb_RegBirthday.Text = reg.regBirthday;
        lb_RegName.Text = reg.regName;
        lb_RegNative.Text = reg.regNative;
        lb_RegSex.Text = reg.regSex;
        lb_School.Text = reg.regSchool;
        lb_Zip.Text = reg.regZip;
    }
    protected void btn_Return_Click(object sender, EventArgs e)
    {
        Response.Redirect("registrationList.aspx");
    }
    protected void btn_Submit_Click(object sender, EventArgs e)
    {
        string stuId = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString()
            + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();

        string card = lb_IDCard.Text.ToString();
        string password = BLL.Cryptography.MD5(card.Substring(card.Length-7,6));
        string name = lb_RegName.Text.ToString();
        int regId = int.Parse(Request.QueryString["id"]);

        if (regBll.Luqu(stuId, password, name, regId))
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "s", "alert('录取成功');window.location.href='registrationList.aspx';", true);
        }
        else
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "s", "alert('遇到问题，无法录取');window.location.href=window.location.href;", true);
        }

    }
}
